require( '$d/css/common.less' );
require( './style.less' );
define( [
  'jquery',
  'require',
  'header',
  'picture_browser',
  'api',
  'bigwe_utils'
], function( $, require ) {
  var BIGWE_API = require( 'api' ),
    getUrlParam = require( 'bigwe_utils' ).getUrlParam,
    pb = require( 'picture_browser' );
  var win_search = window.location.search;

  var pic_cd = getUrlParam( win_search, 'picxx_cd' );
  var pid = getUrlParam( win_search, 'pid' );
  var img_html = '';
  if ( pic_cd ) {
    $.ajax( {
      type: 'post',
      dataType: 'json',
      url: BIGWE_API.SEARCH.GET_IMG_INFO,
      data: {
        'cd': pic_cd
      },
      success: function( data ) {
        var pic_data = data.data;
        pic_data.title = data.data.image_name;
        pic_data.image_id = pic_cd;
        pic_data.img_url = data.data.image;
        pic_data.tags = data.data.tag;
        var img_arr = []
        img_arr.push( pic_data );
        pb.doPreviewPicture( img_arr, undefined, 0 );
      }
    } );
  } else {
    $.ajax( {
      type: 'get',
      dataType: 'json',
      url: '/MyPicture/get_img_info',
      data: {
        'pid': pid,
        user: getUrlParam( win_search, 'user' )
      },
      success: function( data ) {
        var pic_data = data.data;
        pic_data.title = data.data.image_name;
        pic_data.image_id = pid;
        pic_data.img_url = data.data.image;
        pic_data.tags = data.data.tag;
        var img_arr = []
        img_arr.push( pic_data );
        pb.doPreviewPicture( img_arr, undefined, 0 );
      }
    } );
  }
} );
